#!/usr/bin/env python

import sys
import socket

TCP_IP = '127.0.0.1'
TCP_PORT = int(sys.argv[1])
BUFFER_SIZE = 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))


try:
  while True:
    data = s.recv(BUFFER_SIZE)
    if data:
      print "received data:", data
  s.close()
except:
  print "Socket closed"
